<extend name="Layout/page_detail" />
<block name="content">
	<input type="hidden" name="ajax" id="ajax" value="1">
{:W('PageHeader/search',array('name'=>'音视频设备管理','search'=>'S'))}
	<form method="post" id="form_adv_search" name="form_adv_search" method="post">
		<input type="hidden" name="ajax" id="ajax" value="1">
		<div class="operate panel panel-default">
			<div class="panel-body">
				<div class="pull-left">
				</div>
				<div class="pull-right">
					<a onclick="add()"  class="btn btn-sm btn-primary">新增</a>
					<a onclick="save()"  class="btn btn-sm btn-primary">保存</a>
					|
					<a onclick="del()"  class="btn btn-sm btn-danger">删除</a>
				</div>
			</div>
		</div>
	</form>
	<div class="row">
		<div class="col-sm-4 sub_left_menu ">
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>名称</th>
						<th>型号</th>
						<th>保管员</th>
					</tr>
				</thead>
				<tbody>
                <volist name="list" id="data">
						<tr id="{$data.id}">
							<td> {$data.name}</td>
							<td> {$data.edition}</td>
							<td> {$data.storeman}</td>
						</tr>
                </volist>
				</tbody>
			</table>
			<div class="pagination">
                {$page}
			</div>
		</div>
		<div class="col-sm-8">
			<form id="form_data" name="form_data" method="post" class="form-horizontal">
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="opmode" id="opmode" value="edit">
            
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="name">名称*：</label>
                    <div class="col-sm-8">
                        <input type="text" id="name" name="name" class="form-control" check="require">
                    </div>
                </div>                                                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="edition">型号*：</label>
                    <div class="col-sm-8">
                        <input type="text" id="edition" name="edition" class="form-control" check="require">
                    </div>
                </div>                                                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="serial">编号*：</label>
                    <div class="col-sm-8">
                        <input type="text" id="serial" name="serial" class="form-control" check="require">
                    </div>
                </div>                                                                                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="device_type">类型*：</label>
                    <div class="col-sm-8">
                        <select name="device_type" id="device_type" class="form-control" msg="请选择" check="require">
                        <option value="">请选择</option>
                        
						<option value="0">音频设备</option>
						<option value="1">视频设备</option>
						<option value="2">计算机</option>
						<option value="3">辅助设备</option>                        
					</select>
                    </div>
                </div>                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="number">数量*：</label>
                    <div class="col-sm-8">
                        <input type="text" id="number" name="number" class="form-control" check="require">
                    </div>
                </div>                                                                                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="buy_type">购买方式*：</label>
                    <div class="col-sm-8">
                        <select name="buy_type" id="buy_type" class="form-control" msg="请选择" check="require">
                        <option value="">请选择</option>
                        
						<option value="0">配发</option>
						<option value="1">自购</option>                        
					</select>
                    </div>
                </div>                                                                                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="startdate">启用时间*：</label>
                    <div class="col-sm-8">
                        <input type="text" id="startdate" name="startdate" class="form-control input-date" check="require">
                    </div>
                </div>                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="status">状况*：</label>
                    <div class="col-sm-8">
                        <select name="status" id="status" class="form-control" msg="请选择" check="require">
                        <option value="">请选择</option>
                        
						<option value="0">堪用</option>
						<option value="1">损坏</option>                        
					</select>
                    </div>
                </div>                                                
			<div class="form-group  col-sm-6">
                    <label class="col-sm-4 control-label" for="storeman">保管员*：</label>
                    <div class="col-sm-8">
                        <input type="text" id="storeman" name="storeman" class="form-control" check="require">
                    </div>
                </div>                                                                                                <div class="form-group">

                </div>
			</form>

		</div>

	</div>
</block>
<block name="js">
	<script type="text/javascript">
		function add() {
			$("#opmode").val("add");
			$("#id").val("");
			if (check_form("form_data")) {
            sendForm("form_data", "{:U('save')}", "__SELF__");
			}
		};

		function del() {
			var vars = $("#form_data").serialize();
			ui_confirm('确定要删除吗?', function() {
                sendAjax("{:U('del')}", vars, function(data) { 
					if (data.status) {
						ui_alert(data.info, function() {
							location.reload(true);
						});
					}
				});
			});
		}


		function save() {
			if (check_form("form_data")) {
            sendForm("form_data", "{:U('save')}"); 
			}
		}

		function showdata(result) {
			$("#form_data select ").each(function() {
                $(this).find('option').attr('selected', null);
			});
			for (var s in result.data) {
				set_val(s, result.data[s]);
			}
			$("#opmode").val("edit");
		}


		$(document).ready(function() {
			set_return_url();
			$(".sub_left_menu tbody tr").click(function() {
				$(".sub_left_menu tbody tr.active").removeClass("active");
				$(this).attr("class", "active");
                sendAjax("{:U('read')}", "id=" + $(this).attr("id"), function(data) { 
					showdata(data);
				});
				return false;
			});
		});

	</script>
</block>